#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e9 + 7;
ll a[100010];
void solve()
{
    ll n;
    ll flag = 0;
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i] == 1)
        {
            flag = 1;
        }
    }
    if (flag)
        cout << -1 << endl;
    else
        cout << N << endl;
}
int main()
{
    ll t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}